# Maintainer: Caleb Maclennan <caleb@alerque.com>

pkgname=git-branchless
pkgver=0.8.0
pkgrel=1
pkgdesc='High-velocity monorepo-scale workflow for Git'
url="https://github.com/arxanas/$pkgname"
arch=(loong64 x86_64)
license=(GPL2)
depends=(git
         libgit2)
makedepends=(cargo)
checkdepends=(git)
_archive="$pkgname-$pkgver"
source=("$url/archive/v$pkgver/$_archive.tar.gz")
sha256sums=('f9e13d9a3de960b32fb684a59492defd812bb0785df48facc964478f675f0355')

prepare() {
	cd "$_archive"
	cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
	cd "$_archive"
	CFLAGS+=" -ffat-lto-objects"
	cargo build --frozen --release --all-features
}

check() {
	cd "$_archive"
	# https://github.com/arxanas/git-branchless/issues/266
	export TEST_GIT=$(which git) TEST_GIT_EXEC_PATH=$(git --exec-path)
	cargo test --frozen --all-features
}

package () {
	cd "$_archive"
	local _target="target/release/$pkgname"
	install -Dm0755 -t "$pkgdir/usr/bin/" "$_target"
	$_target install-man-pages "$pkgdir/usr/share/man/man1/"
}
